package cn.iocoder.yudao.module.trade.dal.dataobject.fruitcard;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.trade.controller.admin.fruitcard.vo.FruitCardUserExportReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.fruitcard.vo.FruitCardUserPageReqVO;
import cn.iocoder.yudao.module.trade.dal.mysql.fruitcard.FruitCardUserDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 水果卡 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface FruitCardUserMapper extends BaseMapperX<FruitCardUserDO> {

    default PageResult<FruitCardUserDO> selectPage(FruitCardUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FruitCardUserDO>()
                .likeIfPresent(FruitCardUserDO::getPhone, reqVO.getPhone())
                .eqIfPresent(FruitCardUserDO::getUserId, reqVO.getUserId())
                .eqIfPresent(FruitCardUserDO::getCardId, reqVO.getCardId())
                .eqIfPresent(FruitCardUserDO::getPhone, reqVO.getPhone())
                .betweenIfPresent(FruitCardUserDO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(FruitCardUserDO::getDetailId, reqVO.getCardNoRelativeIds())
                .orderByDesc(FruitCardUserDO::getId));
    }

    default List<FruitCardUserDO> selectList(FruitCardUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FruitCardUserDO>()
                .eqIfPresent(FruitCardUserDO::getUserId, reqVO.getUserId())
                .eqIfPresent(FruitCardUserDO::getDetailId, reqVO.getDetailId())
                .eqIfPresent(FruitCardUserDO::getPhone, reqVO.getPhone())
                .betweenIfPresent(FruitCardUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FruitCardUserDO::getId));
    }

}
